<!-- 抢修立项 -->
<template>
  <div style="padding: 15px 30px">
    <el-form class="padding-top-15" :model="model" label-width="120px" size="small" label-position="right">
      <el-row>
        <el-col :span="8">
          <el-form-item label="项目名称">
            <el-input v-model="model.name"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="申请部门">
            <el-input v-model="model.applySection"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="申请人">
            <el-input v-model="model.applyUser"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <div style="display: flex; justify-content: space-between" class="padding-top-15">
        <div class="font-size-16 font-weight-700">项目信息</div>
        <div></div>
      </div>
      <el-row class="padding-top-15" label-width="120px" size="small" label-position="right">
        <el-col :span="8">
          <el-form-item label="事项">
            <el-input v-model="model.chargeItemName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="事项内容">
            <el-input v-model="model.chargeItemDesc"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="预计总金额">
            <el-input v-model="model.totalCost"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="关联设施">
            <el-input v-model="model.totalCost"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="位置">
            <el-input v-model="model.totalCost"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="发生时间">
            <el-date-picker v-model="model.rentEndDate" type="date" value-format="timestamp" clearable placeholder="请选择"></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <div style="display: flex; justify-content: space-between" class="padding-top-15">
        <div class="font-size-16 font-weight-700">付款计划</div>
        <div></div>
      </div>
      <el-row class="padding-top-15" label-width="120px" size="small" label-position="right">
        <div v-for="(item, index) in model.paymentItemListCloudDto" :key="index">
          <el-col :span="10">
            <el-form-item label="付款时间">
              <el-date-picker v-model="item.paymentDate" type="date" value-format="timestamp" clearable placeholder="请选择"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="付款金额">
              <el-input type="number" v-model="item.paymentAmount"></el-input>
            </el-form-item>
          </el-col>
        </div>
        <el-col>
          <el-form-item label="说明：">
            <el-input size="mini" v-model="model.sm" type="textarea" autosize></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div style="display: flex; justify-content: space-between" class="padding-top-15">
      <div class="font-size-16 font-weight-700">历史支出</div>
      <div></div>
    </div>
    <div class="padding-left-10 padding-top-15">
      <el-form ref="form" label-width="120px">
        <el-table class="group-operation-table" :data="tableData" style="width: 60%" border>
          <el-table-column prop="actualPaymentDate" label="时间" align="center"> </el-table-column>
          <el-table-column prop="paymentAmount" label="支出金额" align="center"> </el-table-column>
          <el-table-column prop="fundsDesc" label="事项内容" align="center"> </el-table-column>
        </el-table>
        <!-- <el-form-item label="附件">
          <el-button size="small" type="text">上传附件</el-button>
        </el-form-item> -->
      </el-form>
    </div>
    <approve-info></approve-info>
  </div>
</template>
<script>
import approveInfo from './approveInfo.vue';
import dayjs from 'dayjs';
import Api from '../../api/assetsMap';
export default {
  components: {},
  data() {
    return {
      model: {},
      tableData: [],
    };
  },
  filters: {},
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //接收参数
  props: {},
  //生命周期 - 创建完成（访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {
    this.getDetail();
  },
  //方法集合
  methods: {
    async getDetail() {
      const res = await Api.projectDetails({
        primaryKey: this.$route.query.chargeItemKey,
      });
      if (res && res.success) {
        this.model = res;
        this.getHistorySpending(res.bizId, res.changeItemType);
      }
    },
    async getHistorySpending(bizId, changeItemType) {
      const res = await Api.queryPaymentRecordList({
        changeItemType,
        bizId,
      });
      if (res && res.success) {
        res.rows.forEach(item => {
          if (item.actualPaymentDate) {
            item.actualPaymentDate = dayjs(item.actualPaymentDate).format('YYYY-MM-DD');
          }
        });
        this.tableData = res.rows;
      }
    },
  },
  components: { approveInfo },
};
</script>
<style scoped lang="scss">
.group-operation-table {
  color: #666;
  font-size: 14px;
  font-weight: 400;
  border: 1px solid #ccc;
}
/* @import url(); 引入css类 */
.flex-box {
  height: 50px;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: center;

  justify-content: space-between;
  .large-title {
    font-size: 18px;
  }
}
</style>
